package com.shushan.lockscreen;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.shushan.shushanbao.R;
import com.shushan.ui.CountdownTextView;

/**
 * @ClassName: EyeSleepFloatWindow
 * @Desciption: 视力保护悬浮窗
 * @author: yichaohua
 * @date: 2018-08-06
 */
public class EyeSleepFloatWindow extends LinearLayout implements View.OnClickListener {

    private static final String TAG = "EyeSleepFloatWindow";

    private Context mContext;

    private ImageView leftBackImg;
    private CountdownTextView countdownTextView;

    public EyeSleepFloatWindow(Context mContext) {
        super(mContext);
        this.mContext = mContext;

        LayoutInflater.from(mContext).inflate(R.layout.eye_sleep_window, this);

        initView();
    }

    private void initView() {
        leftBackImg = findViewById(R.id.actionbar_left_back_img);
        leftBackImg.setOnClickListener(this);
        countdownTextView = findViewById(R.id.eye_sleep_count_down_tv);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.actionbar_left_back_img:
                EyeSleepWindowManager.removeEyeFloatWindow(mContext);
                break;
            default:
                break;
        }
    }

    public CountdownTextView getCountdownTextView() {
        return countdownTextView;
    }

    public void setCountdownTextView(CountdownTextView countdownTextView) {
        this.countdownTextView = countdownTextView;
    }


    public void setStartGone() {
        countdownTextView.setText("05:00");
        countdownTextView.setTimes(5*60);
    }
}
